﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Manon.Repository
{
    /// <summary>
    /// 数据库字段类型
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = false)]
    public class DbColumnAttribute : Attribute
    {
        public DbColumnAttribute()
        {
            this.ColumnType = ColumnType.Default;
            this.AlwaysUpdate = false;
        }

        public DbColumnAttribute(ColumnType columnType)
        {
            this.ColumnType = columnType;
            this.AlwaysUpdate = false;
        }

        public DbColumnAttribute(ColumnType columnType,bool alwaysUpdate)
        {
            this.ColumnType = columnType;
            this.AlwaysUpdate = alwaysUpdate;
        }

        public ColumnType ColumnType { get; set; }

        /// <summary>
        /// 是否一直操作  false 只在插入时变更值， true 新增、修改都变更值
        /// </summary>
        public bool AlwaysUpdate { get; set; } = false;
    }

    /// <summary>
    /// 数据库id自增类型
    /// </summary>
    public enum ColumnType
    {
        /// <summary>
        /// 默认数据库自增
        /// </summary>
        [Description("默认数据库自增")]
        Default = 0,

        /// <summary>
        /// 雪花算法
        /// </summary>
        [Description("雪花算法")]
        SnowFlake = 1,

        /// <summary>
        /// Redis 该方法未实现
        /// </summary>
        [Description("Redis")]
        Redis = 3,

        /// <summary>
        /// Guid
        /// </summary>
        [Description("Guid")]
        Guid = 4
    }
}
